package updater;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import java.awt.Color;

public class Popup {
	
	
	private static JFrame parentFrame;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(() -> {
                    Popup window;
                    try {
                        window = new Popup();
                        Popup.parentFrame.setVisible(true);
                    } catch (Exception e) {
                    }
                });
		
	}
	
	public Popup() {
		initialize();
	}
	
	/**
	 * @wbp.parser.entryPoint
	 */
	private void initialize(){
		parentFrame = new JFrame();
		parentFrame.setTitle("Updating...");
	    parentFrame.setSize(406, 145);
	    parentFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    parentFrame.getContentPane().setLayout(null);
	    	    
	    JProgressBar progressBar = new JProgressBar();
	    progressBar.setForeground(Color.GREEN);
	    progressBar.setToolTipText("Update is running");
	    progressBar.setIndeterminate(true);
	    progressBar.setBounds(10, 24, 370, 20);
	    parentFrame.getContentPane().add(progressBar);
	    
	    JButton btnNewButton = new JButton("Cancel");
	    btnNewButton.addMouseListener(new MouseAdapter() {
	    	@Override
	    	public void mouseClicked(MouseEvent arg0) {
	    		System.exit(0);	    		
	    		}
	    });
	    btnNewButton.setBounds(131, 64, 126, 31);
	    parentFrame.getContentPane().add(btnNewButton);

	    parentFrame.setVisible(true);

	    
	  }
	
	public static void close(){
		parentFrame.disable();
	}

}
